﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.IO;
using log4net;
using log4net.Util;

namespace Eshouse.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //默认匹配
            //routes.MapRoute("NoAction", "{controller}", new { controller = "home", action = "index", id = "" });
            ////无Action的匹配
            //routes.MapRoute("NoID", "{controller}/{action}", new { controller = "home", action = "index", id = "" });
            ////无ID的匹配
            //routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "home", action = "index", id = "" });
            ////默认匹配
            ////routes.MapRoute("Root", "",  new { controller = "home", action = "index", id = "" });//根目录匹配

            routes.MapRoute(
               "Default1", // Route name
               "{controller}/{action}/{id}", // URL with parameters
               new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
           );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
            ///启动log记录
            string logpath = Server.MapPath("~/log4net.config");
            log4net.Config.XmlConfigurator.Configure(new FileInfo(logpath));
        }
    }
}